﻿using System.ComponentModel;
using System.Drawing;
using System.Xml.Serialization;
using CodeSnippet.Formats;
using CodeSnippet.Forms;
using CodeSnippet.Options;
using CodeSnippet.Properties;

namespace CodeSnippet.Config
{
    /// <summary>
    /// General section of the Code Snippet plugin configuration.
    /// </summary>
    [DefaultProperty("SectionName")]
    public class GeneralConfig : IConfigSection
    {
        #region Properties
        /// <summary>
        /// Gets the name of the section.
        /// </summary>
        /// <value>The name of the section.</value>
        [LocalizedCategory("CategoryAttribute_Attributes"), LocalizedDisplayName("DisplayNameAttribute_SectionName"), LocalizedDescription("DescriptionAttribute_SectionName"), XmlIgnore]
        public string SectionName
        {
            get { return Resources.ConfigSectionName_General; }
        }
        /// <summary>
        /// Gets the image.
        /// </summary>
        /// <value>The image.</value>
        [Browsable(false), XmlIgnore]
        public Bitmap Image
        {
            get { return Resources.general; }
        }
        /// <summary>
        /// Flag indicating whether or not to run in silent mode.
        /// </summary>
        /// <remarks>
        /// Silent mode allows for the quick pasting of formatted source code using the last configuration.
        /// </remarks>
        [Category("Behavior"), LocalizedDisplayName("DisplayNameAttribute_RunSilent"), LocalizedDescription("DescriptionAttribute_RunSilent")]
        public bool RunSilent { get; set; }
        /// <summary>
        /// Zero-based index value indicating the language selected.
        /// </summary>
        [Browsable(false)]
        public SupportedFormatType ActiveLanguage { get; set; }
        /// <summary>
        /// Active view mode, one of <see cref="CodeSnippetViewMode.Compact"/> or <see cref="CodeSnippetViewMode.Full"/>.
        /// </summary>
        [Category("Layout"), LocalizedDisplayName("DisplayNameAttribute_ActiveMode"), LocalizedDescription("DescriptionAttribute_ActiveMode")]
        public CodeSnippetViewMode ActiveMode { get; set; }
        /// <summary>
        /// Active view, one of <see cref="CodeSnippetViewType.CodeSnippet"/>, <see cref="CodeSnippetViewType.FormattedCodeSnippet"/>, or <see cref="CodeSnippetViewType.Both"/>.
        /// </summary>
        [Category("Layout"), LocalizedDisplayName("DisplayNameAttribute_ActiveView"), LocalizedDescription("DescriptionAttribute_ActiveView")]
        public CodeSnippetViewType ActiveView { get; set; }
        #endregion Properties

        #region Initialiazation
        /// <summary>
        /// Initializes a new instance of the <see cref="GeneralConfig"/> class.
        /// </summary>
        public GeneralConfig()
        {
            // Behavior
            RunSilent = false;
            // Layout
            ActiveView = CodeSnippetViewType.Both;
            ActiveMode = CodeSnippetViewMode.Full;
            ActiveLanguage = SupportedFormatType.CSharp;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GeneralConfig"/> class.
        /// </summary>
        /// <param name="copy">The <see cref="GeneralConfig"/> instance from which to copy.</param>
        public GeneralConfig(GeneralConfig copy)
        {
            // Behavior
            RunSilent = copy.RunSilent;
            // Layout
            ActiveLanguage = copy.ActiveLanguage;
            ActiveMode = copy.ActiveMode;
            ActiveView = copy.ActiveView;
        }
        #endregion Initialiazation
    }
}
